package com.atguigu.gmall.gateway.filter;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.gateway.filter.GatewayFilterChain;
import org.springframework.cloud.gateway.filter.GlobalFilter;
import org.springframework.core.Ordered;
import org.springframework.stereotype.Component;
import org.springframework.web.server.ServerWebExchange;
import reactor.core.publisher.Mono;

/**
 * title:
 * author: Gyh
 * date:2023-04-25 19:26
 * Description:
 */
@Component
public class TestFilter implements GlobalFilter, Ordered {

    @Value("${server.port}")
    private Integer port;

    @Override
    public Mono<Void> filter(ServerWebExchange exchange, GatewayFilterChain chain) {
        System.out.println("服务被请求，端口号:"+port);
        return chain.filter(exchange);
    }

    @Override
    public int getOrder() {
        return -100;
    }
}
